public class test_MyTime {
        public static void main(String[] args) {
            // 测试构造函数和 toString 方法
            MyTime time1 = new MyTime(13, 30, 15);
            System.out.println("Time 1 (12-hour format): " + time1.toString());
            System.out.println("Time 1 (24-hour format): " + time1.toUniversalString());

            // 测试 incrementSecond 方法
            MyTime time2 = new MyTime(11, 59, 59);
            System.out.println("\nBefore incrementing second: " + time2.toString());
            time2.incrementSecond();
            System.out.println("After incrementing second: " + time2.toString());

            // 测试 incrementMinute 方法
            MyTime time3 = new MyTime(12, 59, 59);
            System.out.println("\nBefore incrementing minute: " + time3.toString());
            time3.incrementMinute();
            System.out.println("After incrementing minute: " + time3.toString());

            // 测试 incrementHour 方法
            MyTime time4 = new MyTime(23, 59, 59);
            System.out.println("\nBefore incrementing hour: " + time4.toString());
            time4.incrementHour();
            System.out.println("After incrementing hour: " + time4.toString());

            // 测试不合法时间输入
            try {
                MyTime invalidTime = new MyTime(25, 60, 60);
                System.out.println("\nInvalid time should throw an exception: \n" + invalidTime.toString());
            } catch (IllegalArgumentException e) {
                System.out.println("\nCaught expected exception: " + e.getMessage());
            }
        }
}
